const {db} = require("../util/util")


const addEvent = (host,describe,create_time,start_time,end_time) => {//添加一个投票事件
  const sql = "insert into event (host,`describe`,create_time,start_time,end_time) values(?,?,?,?,?)";//坑 describe
  return db.execute(sql,[host,describe,create_time,start_time,end_time]).then((data) => {
    console.log(data[0].insertId)
    return data[0].insertId;
  })
}

const getAllEvents = () => {//获取所有投票事件
  const sql = "select * from event"
  return db.execute(sql).then((data) => {
    return data[0];//获取event列表
  })
}


module.exports = {addEvent, getAllEvents}


